package com.bwie.rent.controller;

import java.util.Arrays;
import java.util.Map;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.bwie.rent.entity.PayEntity;
import com.bwie.rent.service.PayService;
import com.bwie.common.utils.PageUtils;
import com.bwie.common.utils.R;



/**
 * 
 *
 * @author lfw
 * @email sunlightcs@gmail.com
 * @date 2022-03-27 10:18:41
 */
@RestController
@RequestMapping("rent/pay")
public class PayController {
    @Autowired
    private PayService payService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = payService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{payId}")
    public R info(@PathVariable("payId") Integer payId){
		PayEntity pay = payService.getById(payId);

        return R.ok().put("pay", pay);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    public R save(@RequestBody PayEntity pay){
		payService.save(pay);

        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    public R update(@RequestBody PayEntity pay){
		payService.updateById(pay);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestBody Integer[] payIds){
		payService.removeByIds(Arrays.asList(payIds));

        return R.ok();
    }

}
